function chai(str) {
	let prev;
	let areas;
	let cs = [];
	if (str.indexOf("省") !== -1) {
		prev = str.slice(0, str.indexOf("省") + 1);
	} else {
		if (str.indexOf("自治区") !== -1) {
			prev = str.slice(0, str.indexOf("自治区") + 3);
		} else {
			prev = str.slice(0, str.indexOf("市") + 1);
		}
	}
	str = str.replace(prev, "");
	if (str.indexOf("辖县") !== -1) {
		areas = str.slice(0, str.indexOf("辖县") + 2);
	} else {
		if (str.indexOf("单位") !== -1) {
			areas = str.slice(0, str.indexOf("单位") + 2);
		} else {
			if (str.indexOf("盟") !== -1) {
				areas = str.slice(0, str.indexOf("盟") + 1);
			} else {
				if (str.indexOf("州") !== -1) {
					areas = str.slice(0, str.indexOf("州") + 1);
				} else {
					if (str.indexOf("地区") !== -1) {
						areas = str.slice(0, str.indexOf("地区") + 2);
					} else {
						areas = str.slice(0, str.indexOf("市") + 1);
					}
				}
			}
		}
	}
	str = str.replace(areas, "");
	cs.push(prev);
	cs.push(areas);
	cs.push(str);
	return cs;
}

function setCookie(key, value, expires) {
	if (typeof expires === "object") {
		document.cookie = `${key}=${value};expires=${expires}`;
	}
	if (typeof expires === "number") {
		let data = new Date();
		data.setDate(data.getDate() + expires);
		document.cookie = `${key}=${value};expires=${data}`;
	}
}

function getCookie(s) {
	let arr = document.cookie.split("; ");
	let result = {};
	arr.forEach(item => {
		let arrvr = item.split("=");
		result[arrvr[0]] = arrvr[1];
	})
	if (!s) {
		return result;
	}
	return result[s];
}

function removeCookie(key) {
	let del = new Date("2020/09/09 00:00:00")
	document.cookie = `${key}="";expires=${del}`
}
